/**
 * @file src/MotifTree.cpp
 *
 * @date 28-aug-2013
 *
 * @author Youri Hoogstrate
 *
 * @section LICENSE
 * yh-kt-fold can predict RNA 2D structures including K-turns.
 * Copyright (C) 2012-2013 Youri Hoogstrate
 *
 * This file is part of yh-kt-fold.
 *
 * yh-kt-fold is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * yh-kt-fold is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */



#include "MotifTree.h"



/**
 * @brief
 *
 * @date 25-jul-2013
 */
MotifTree::MotifTree()
{
	this->root = NULL;
}



/**
 * @brief
 *
 * @date 25-jul-2013
 */
MotifTree::~MotifTree()
{
	delete this->root;
}



/**
 * @brief
 *
 * @date 25-jul-2013
 */
Motif *MotifTree::search_motif(const std::string &arg_motif5p, const std::string &arg_motif3p)
{
	/*
	int a = 5;
	const int &b = a;
	b = 3;
	printf("[%i]\n",b);
	*/
	
	int search_type = 1;
	
	// First find the binary tree with motifs of the specific length
	if(this->root != NULL)
	{
		return this->root->search_motif(arg_motif5p, arg_motif3p, search_type);
	}
	else
	{
		return NULL;
	}
}



/**
 * @brief Adds a Motif (as member of a MotifTreeElement) to the tree.
 *
 * @date 28-aug-2013
 */
void MotifTree::add_motif(Motif *arg_motif)
{
	int search_type = 1;
	
	if(this->root != NULL)
	{
		//printf("\n Hooked into root\n");
		this->root->add_motif(arg_motif, search_type);					/** @todo find some constant for '1' */
	}
	else
	{
		MotifTreeElement *element;
		element = new MotifTreeElement(arg_motif);
		this->root = element;
		//printf("\n New root\n");
	}
}
